var back = document.getElementById("back");
var times = document.getElementById("times");
var a = 60;
var submit1 = document.getElementById("submit1");
back.addEventListener("touchstart", function() {
	window.history.go(-1);
})
submit1.addEventListener("touchstart", function(event) {
	event.preventDefault();
	this.style.background = "#e8201e";
	var tel = document.querySelector("#tel");
	var pwd1 = document.querySelector("#pwd1");
	var pwd2 = document.querySelector("#pwd2");
	var yzm = document.querySelector("#yzm");
	if(tel.value == "") {
		tel.placeholder = "请输入手机号";
		tel.setAttribute("class", "name2");
	}
	if(tel.value != "" && !/^[1][3,4,5,7,8][0-9]{9}$/.test(tel.value)) {
		tel.value = "";
		tel.placeholder = "请输入正确手机号";
		tel.setAttribute("class", "name");
	}
	if(/^[1][3,4,5,7,8][0-9]{9}$/.test(tel.value) && pwd1.value == "") {
		pwd1.placeholder = "请输入密码";
		pwd1.setAttribute("class", "name2");
	}
	if(/^[1][3,4,5,7,8][0-9]{9}$/.test(tel.value) && pwd1.value != "" && pwd1.value.length < 6) {
		pwd1.value = "";
		pwd1.placeholder = "密码长度不得小于六位";
		pwd1.setAttribute("class", "name");
	}
	if(/^[1][3,4,5,7,8][0-9]{9}$/.test(tel.value) && pwd1.value != "" && pwd2.value == "") {
		pwd2.placeholder = "请输入确认密码";
		pwd2.setAttribute("class", "name2");
	}
	if(/^[1][3,4,5,7,8][0-9]{9}$/.test(tel.value) && pwd2.value != "" && pwd1.value != pwd2.value) {
		pwd2.value = "";
		pwd2.placeholder = "确认密码与密码不符";
		pwd2.setAttribute("class", "name");
	}
	if(/^[1][3,4,5,7,8][0-9]{9}$/.test(tel.value) && pwd2.value != "" && pwd1.value == pwd2.value && yzm.value == "") {
		yzm.placeholder = "请输入验证码";
		yzm.setAttribute("class", "name2");
	}

})
submit1.addEventListener("touchend", function(event) {
	this.style.background = "#f23a38";
})
//			验证码倒计时
function time() {
	timer = setInterval(function() {
		a--;
		if(a <= 0) {
			clearInterval(timer);
		}
		times.innerHTML = a + "s";
	}, 1000);
	time2 = setTimeout(function() {
		times.style.color = "#f23a38";
		times.innerHTML = "已超时";
	}, 61000);
}
yanzheng.addEventListener("touchstart", function() {
	times.style.display = "block";
	time();
})